/*
 * ImageFilter.java
 *
 * Created on 2007/12/21, 4:45
 *
 *
 * 
 */

package monoliner;

/**
 *
 * @author 101000LAB
 */

import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;

public class ImageFilter extends FileFilter{
        public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        /* 拡張子を取り出す */
        String ext = "";
        String s = f.getName();
        int i = s.lastIndexOf('.');
        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }

        if (ext.equals("jpg")||ext.equals("png")||ext.equals("gif")){
            return true;
        } else {
            return false;
        }
    }
 
   public String getDescription() {
        return "Image File";
    }
}
